﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Pulog.Models
{
    public partial class CommentRepository : ICommentRepository
    {
        private readonly PulogDataContext dc = new PulogDataContext();

        #region IComment Members

        public List<Comment> GetCommentstByPostSlug(PostRepository p)
        {
            //dc.Comments.Select<Post,Comment>(c => c.
            throw new NotImplementedException();
        }

        public List<Comment> GetCommentsByPostId(int id)
        {
            var comments = (from c in dc.Comments
                            where c.PostID == id
                            select c).OrderByDescending(c => c.CommentTime);
            return comments.ToList<Comment>();
        }

        public Comment GetCommentById(int id)
        {
            return dc.Comments.Single(c => c.CommentID == id);
        }


        public List<Comment> GetCommentList()
        {
            throw new NotImplementedException();
        }

        public void InsertComment(Comment post)
        {
            throw new NotImplementedException();
        }

        public void UpdateComment(Comment post)
        {
            throw new NotImplementedException();
        }

        public void DeleteComment(Comment post)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    public partial class Comment
    {
        public List<Comment> ChildrenComments
        {
            set;
            get;
        }
    }
}